#单分支选择结构_条件表达式详解
# num=1
# if num < 5:
#     print("小于5的整数："+str(num))

# num=input("输入一个数字：")
# if int(num) < 10:
#       print("小于10的整数: "+str(num))


#大于0的数字表示为True 0表示False
# if 3:
# #     print("ok")
# c=7
# if c < 9:
#     print("c<9")



#多分支选择结构
# score=int(input("请输入分数:"))  #因为input默认输入的是字符串所以输入需要一个强转类型int()
# grade=""
# if (score<60):
#     grade="不及格"
# if (60<=score<80):
#     grade="及格"
# if(80<=score<90):
#     grade="良好"
# if(score>=90):
#     grade="优秀"
# print("分数是{0},等级是{1}".format(score,grade))

#选择结构的嵌套
# score=int(input("输入一个在0到100之间的数字:"))
# grade=""
# if score>100 or score<0:
#     score=int(input("请重新输入一个0到100之间的数字:"))
# else:
#     if score>=90:
#         grade="A"
#     elif score>=80:
#         grade="B"
#     elif score>=70:
#         grade="C"
#     elif score>=60:
#         grade="D"
#     else:
#         grade="E"
# print("分数是{0},等级是{1}".format(grade,score))

#while循环结构_死循环处理
#利用while循环打印1-10:
# num=0
# while num<10:
#     print(num,end=" ") #0 1 2 3 4 5 6 7 8 9 不换行打印
#     num+=1

#利用while打印1—100的和
# num=0
# sum_all=0
#
# while num<=100:
#
#     sum_all+=num
#     num += 1
#     print(sum_all)

# for循环结构_遍历各种可迭代对象_range对象
# for x in (20,30,40):
#     print(x*10,end=" ")
#     for temp in "gaoqi":
#         print(temp,end=" ")

d={"name":"guanyu","age":19,"job":"student"}
# for x in d:
#     print(x)
# for x in d.keys():
#         print(x)
# for x in d.values():
#             print(x,end=" ") #guanyu 19 student
# for x in d.items():
#     print(x,end=" ") #('name', 'guanyu') ('age', 19) ('job', 'student')

# for x in range(3,10):
#     print(x,end="\t") #3	4	5	6	7	8	9,\t制表符

#计算1-100之间偶数的累加和，计算1-100之间奇数的累加和
# sum_all=0
# sum_even=0
# sum_odd=0
# for num in range(101):
#     sum_all+=num
# if num%2==0:
#     sum_even+=num
#     else:
#     sum_odd+=sum
#     print("1-100之间的累加和{0},1-100之间偶数的累加和{1},1-100之间奇数的累加和{2}".format(sum_all,sum_even,sum_odd))

#嵌套循环
# for x in range(5):
#     print(0,end="\t")
#     print()
# for x in range(5):
#     print(1, end="\t")
#     print()
# for x in range(5):
#     print(2, end="\t")
#     print()#0	0	0	0	0	1	1	1	1	1	2	2	2	2	2

# for x in range(5):
#     for y in range(5):
#         print(x ,end="\t")
#     print()

# 嵌套循环练习_九九乘法表_打印表格数据
# for m in range (1,10):
#   for n in range (1,m+1):
#      print("{0}*{1}*{2}".format(m,n,(m*n)),end="\t")
#   print()

# a1=dict(name="陈冠宇",age=18,salary="30000",city="上海")
# a2=dict(name="赵星硕",age=10,salary=20000,city="郑州")
# a3=dict(name="张若愚",age=38,salary=10000,city="厦门")
# tb=[a1,a2,a3]
# for x in tb:
#     if int(x.get("salary"))>15000:
#         print(x.get("name")) #陈冠宇 赵星硕


#break语句
# while True:
#     a=input("请输入一个字符:(输入Q/q表示结束)")
#     if a=="Q"or a=="q":
#         print("循环结束")
#         break
#     else:
#         print("输入错误:"+a)
#         break


# #continue语句
# empNum=5
# salarySum=0
# salarys=[]
# while True:
#     s=input("请输入员工的薪资：(按q或者Q结束)")
#     if s.upper()=="Q":
#         print("录入结束")
#         break
#     if float(s)<0:
#         print("无效!继续录入!")
#         continue
#         print("录入成功")
#         empNum+=1
#     salarys.append(float(s)) #列表对象把上一个员工薪资放进去
#     salarySum+=float(s) #累加员工薪资
#     print("员工数{0}".format(empNum))
#     print("录入薪资：",salarys)
#     print("总发薪资:",salarySum)
#     print("平均薪资{0}".format(salarySum/empNum))


#zip（）并行迭代多个序列
# names=("陈冠宇","畅子丫","李谭生","马文博")
# ages=(18,19,20,21)
# jobs=("老师","医生","学生","公务员")
# for names,ages,jobs in zip(names,ages,jobs):
#     print("{0}--{1}--{2}".format(names,jobs,ages))
# for i in range(min(len(names),len(ages),len(jobs))):
#         print("{0}--{1}--{2}".format(names[i], jobs[i], ages[i])) #效果一样


#推导式创建序列_列表推导式_字典推导式_集合推导式_生成器推导式
# a=[x for x in range(1,10) if x%2==0]
# print(a)

# b=[]
# for x in range (1,10):
#     if x %2==0:
#      b.append(x)
# print(b)


#列表推导式
# cells=[(row,col) for row,col in zip(range(1,10),range(101,110))]
# for cell in cells:
#     print(cell)


#字典推导式
# values={"北京","上海","深圳","广州"}
# cities={id:city for id,city in zip(range(1,5),values) }
# print(cities)    #{1: '广州', 2: '北京', 3: '深圳', 4: '上海'}


#推导式创建列表
# my_test='i love you,i love sxt,i love czy'
# char_count={c:my_test.count(c) for c in my_test}
# print(char_count)


#绘制不同颜色的同心圆_绘制棋盘
# import turtle
# p=turtle.Pen()  #画笔对象
# radius=[x*10 for x in range(1,11)]  #定义圆的半径
# my_colors=("red","green","black","pink")
# p.width(4)
# for r,i in zip(radius,range(len(radius))):
#     p.penup() #把笔抬起来不显示那根线
#     p.goto(0,-r)
#
#     p.pendown()
#     p.color(my_colors[i%len(my_colors)])
#     p.circle(r)
#
# turtle.done()#程序停住不结束